<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>{{index}}</p>
        <button @click="add(1)">+1</button>
        <button v-on:click="sub(1)">-1</button>
    </div>
    <!-- 导入vue库文件 -->
    <script src="./lib/vue-2.6.12.js"></script>
    
    <!-- 创建vue实例对象 -->
    <script>
        const vm = new Vue({
            //告诉vue要控制哪个区域
            el: '#app',
            //data就是要渲染的数据
            data: {
                index: 0,
            },
            methods: {
                add(n) {
                    this.index += n
                },
                sub(n) {
                    this.index -= n
                }
            }
        })
    </script>
</body>
</html>